import Vue from 'vue'
import axios from 'axios'
import qs from 'qs'
// 配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// axios.defaults.headers.common['Authorization'] = sessionStorage.getItem('token')
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
axios.defaults.transformRequest = [
    function (data) {
        data = qs.stringify(data);
        return data;
    }
]

// 请求拦截器
axios.interceptors.request.use(config => {
    config.headers.Authorization = sessionStorage.getItem('token');
    return config;
});

Vue.prototype.$http = axios;